home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 27
/
CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso
/
SearchCD.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-08-19
|
7KB
|
202 lines
/* Search CD */
VerStr = '$VER: SearchCD 1.0 (12.12.98)'
VerStr = subword(VerStr,2)||'0a'x||'(c) Neil Bothwick, Wirenet'
/* ;;; Initialise */
options results
address command
OutFile = 'RAM:SearchCD_results'
if exists('ENVARC:CUCD/CUCDIndex') then CUCDPath = AddPart(GetVar('CUCD/CUCDIndex'),'')
else CUCDPath = 'CDSupport/indices/'
if exists('ENVARC:CUCD/AminetIndex') then AminetPath = AddPart(GetVar('CUCD/AminetIndex'),'')
else AminetPath = 'CUCD/CDROM/AminetCDs/'
GuiPort = 'SEARCHCD'
PrgPort = 'SEARCHCD.1'
GuiFile = 'SearchCD.mrx'
MUIA_List_Quiet = 0x8042d8c7
MUIM_List_Select = 0x804252d8
MUIV_List_Select_All = -2
MUIV_List_Select_On = 1
MUIV_List_Select_Ask = 3
MUIA_List_First = 0x804238d4
MUIM_List_Remove = 0x8042647e
MUIV_List_Remove_Selected = -3
MUIA_Listview_MultiSelect = 0x80427e08
MUIV_Listview_MultiSelect_Default = 1
MUIA_Gauge_Current = 0x8042f0dd
MUIA_Gauge_Divide = 0x8042d8df
MUIA_Gauge_Horiz = 0x804232dd
MUIA_Gauge_InfoText = 0x8042bf15
MUIA_Gauge_Max = 0x8042bcdb
MUIA_List_Entries = 0x80421654
MUIA_List_Quiet = 0x8042d8c7
MUIA_Application_Active = 0x804260ab
MUIA_Application_Author = 0x80424842
MUIA_Application_Copyright = 0x8042ef4d
MUIA_Application_Description = 0x80421fc6
MUIA_Application_HelpFile = 0x804293f4
MUIA_Application_Iconified = 0x8042a07f
MUIA_Application_Title = 0x804281b8
MUIA_Application_Version = 0x8042b33f
MUIA_Application_Sleep = 0x80425711
MUIM_Application_AboutMUI = 0x8042d21d
TRUE = 1
FALSE = 0
;;;
/* ;;; Open arexx port and GUI */
thisport = openport(PrgPort)
if thisport = 0 then exit
if ~show('P',GuiPort) then 'run >NIL: muirexx' GuiFile 'port' GuiPort
'waitforport' GuiPort
do until cmd = 'READY'
call waitpkt(PrgPort)
packet = getpkt(PrgPort)
cmd = getarg(packet)
call reply(packet,0)
end
address(GuiPort)
call LoadList()
'application' MUIA_Application_Version '$VER: SearchCD 1.0 (12.12.98)'
'application' MUIA_Application_Author 'Neil Bothwick'
'application' MUIA_Application_Copyright '© 1998 by Neil Bothwick, Wirenet'
'application' MUIA_Application_Title 'SearchCD'
'application' MUIA_Application_Description 'Search CUCD and Aminet index files'
;;;
/* ;;; Load libraries */
call LoadLib('rexxsupport.library')
call LoadLib('rexxdossupport.library')
call LoadLib('rexxreqtools.library')
;;;
/* ;;; Main loop */
do forever
call waitpkt(PrgPort)
packet = getpkt(PrgPort)
if packet = '0000 0000'x then iterate
cmd = getarg(packet)
call reply(packet,0)
select
;;;
;;; /* Search */
when cmd = 'SEARCH' then do
'list id CDLST attrs' MUIA_List_Quiet TRUE
'application' MUIA_Application_Sleep TRUE
/* Get search string */
'string id SCSTR'
SearchStr = result
/* Get list of CDs to search */
drop CDs.
i = 0
do forever
list id CDLST
if result = '' then break
i = i + 1
CDs.i = result
end
CDs.0 = i
select
when SearchStr = '' then call ReqMsg('You must specify a string to search for')
when CDs.0 = 0 then call ReqMsg('You must select at least one CD to search')
otherwise call Search()
end
'application' MUIA_Application_Sleep FALSE
'list id CDLST attrs' MUIA_List_Quiet FALSE
end
;;;
;;; /* Select All */
when cmd = 'ALL' then do
'method id CDLST' MUIM_List_Select MUIV_List_Select_All MUIV_List_Select_On
end
;;;
;;; /* Rescan */
when cmd = 'RESCAN' then call LoadList()
;;;
;;; /* About */
when cmd = 'ABOUT' then call ReqMsg(VerStr||'0a'x||'Programmed using MUIrexx')
when cmd = 'ABOUTMUI' then 'method ' MUIM_Application_AboutMUI 0
;;;
;;; /* Cancel */
otherwise call CleanUp()
end
end
;;;
/* ;;; Subroutines */
;;;
/* ;;; Load a library */
LoadLib:
parse arg library
if ~show('L',library) then do
if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
end
return
;;;
/* ;;; Show a message in a requester */
ReqMsg:
parse arg msg
oldaddr = address()
address(GuiPort)
'request id MAIN title "CUCD Search" gadgets "OK" string' msg
choice = result
address(oldaddr)
return choice
;;;
/* ;;; Exit with a requester */
ExitMsg:
parse arg msg
call ReqMsg(msg)
call Cleanup()
return
;;;
/* ;;; Cleanup and exit */
CleanUp:
address command 'delete >NIL:' OutFile'#?'
address(GuiPort)
'QUIT'
exit
;;;
/* ;;; Search CDs */
Search:
address command 'delete >NIL:' OutFile
'gauge id PROGR attrs' MUIA_Gauge_Max CDs.0 MUIA_Gauge_InfoText '%ld/'CDs.0
do i = 1 to CDs.0
'gauge id PROGR attrs' MUIA_Gauge_Current i
if length(CDs.i) = 5 then Infile = IndexPath'CUCD0'substr(CDs.i,5,1)
else Infile = IndexPath||CDs.i
if IndexPath = AminetPath then address command 'echo "*NAminet'substr(InFile,length(Infile) - 1)'" >>'OutFile
address command 'FlashFind >>'OutFile InFile '"'SearchStr'" NOPREFS QUIET'
end
/* Show matches or warn if none */
if word(statef(OutFile),2) = 0 then call ReqMsg('No matches found for "'SearchStr'"')
else address command 'Multiview' OutFile
'gauge id PROGR attrs' MUIA_Gauge_Current 0 MUIA_Gauge_InfoText '""'
return
;;;
/* ;;; List CDs for searching */
LoadList:
address(GuiPort)
'list id CDLST attrs' MUIA_List_Quiet TRUE
'application' MUIA_Application_Sleep TRUE
/* Clear list */
'method id CDLST' MUIM_List_Select MUIV_List_Select_All MUIV_List_Select_On
'method id CDLST' MUIM_List_Remove MUIV_List_Remove_Selected
/* Check which set of CDs to search */
'cycle id CDTYP'
if result = 'CU Amiga' then IndexPath = CUCDPath
else IndexPath = AminetPath
/* Load list */
address command 'list' IndexPath 'pat (Index|CUCD)?? lformat "%N" to' OutFile
address command 'sort' OutFile OutFile'1'
if ~open(listfile,OutFile'1','R') then call ExitMsg('Error reading file')
do while ~eof(listfile)
line = readln(listfile)
if line > '' then 'list id CDLST insert string' line
end
call close(listfile)
'application' MUIA_Application_Sleep FALSE
'list id CDLST attrs' MUIA_List_Quiet FALSE
return
;;;